package networks.protocol;

import networks.event.Delegate;

public class HandshakeService {
    private Protocol _protocol;
    private Delegate.Action _callback;

    public final String Version = "0.0.1";
    public final String Type = "java-socket";

    public HandshakeService(Protocol protocol) {
        _protocol = protocol;
    }

    public void Request(Delegate.Action callback) {
        _protocol.Send(PackageType.PKG_HANDSHAKE);
        _callback = callback;
    }

    public void InvokeCallback(Message_Handshake data) {
        // Invoke the handshake callback
        System.out.println("Handshake! " + data.heartbeat + "(秒)-" + data.route.length + "(个)");
        _callback.Invoke();
    }

    public void Ack() {
        // _protocol.send(PackageType.PKG_HANDSHAKE_ACK);
    }

    private void buildMsg(Object user) {
        // Build sys option
        // sys["version"] = Version;
        // sys["type"] = Type;

        // Build handshake message
        // msg["sys"] = sys;
        // msg["user"] = user;
    }
}
